<html>
<body>

<!--   -->
<!-- Local Scope

A variable declared within a PHP function is local and can only be accessed within that function  -->
<?php
$c = 5; // global scope

function myTest1()
{
$c=10;
echo $c; // local scope
} 

myTest1();
?>



<!-- Global Scope

Global scope refers to any variable that is defined outside of any function.

Global variables can be accessed from any part of the script that is not inside a function.

To access a global variable from within a function, use the global keyword  -->

<?php
$a = 5;
$b = 10;

function myTest()
{
// global $a, $b;

//    $b = $a + $b;
$GLOBALS["b"] = $GLOBALS["a"] + $GLOBALS["b"];
} 

myTest();
echo "<br />".$b;
?>


<!--   -->

</body>
</html>